import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';
import { Api } from './api';

import { RenderType } from '@pkg/setting';
import {render} from "@apps/antd-admin/src/hooks/render/renderUtils";

export const columns: BasicColumn[] = [
  {
    title: '头像',
    dataIndex: 'avatar',
    width: 80,
    renderType: RenderType.AVATAR,
  },
  {
    title: '昵称',
    dataIndex: 'nickName',
    width: 100,
  },

  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 110,
  },

  {
    title: '状态',
    dataIndex: 'status',
    width: 120,
    align: 'center',
    rowKey: 'userId',
    renderApi: Api.setUserStatus,
    customRender: render.renderSwitch,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'nickName',
    label: '昵称',
    component: 'Input',
    colProps: { span: 4 },
  },
 /* {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 4 },
  },*/
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
];

export const editUserFormSchema: FormSchema[] = [
  {
    field: 'userId',
    label: '用户Id',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    field: 'nickName',
    label: '昵称',
    component: 'Input',
    required: false,
  },
 /* {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    required: false,
  },
  {
    field: 'sex',
    label: '性别',
    component: 'Select',
    required: false,
    componentProps: {
      options: [
        { label: '女', value: 1 },
        { label: '男', value: 2 },
      ],
    },
  },*/

  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    required: false,
  },
];

export const changeMobileFormSchema: FormSchema[] = [
  {
    field: 'userId',
    label: '用户Id',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    field: 'mobile',
    label: '会员手机号',
    component: 'Input',
    rules: [
      { required: true, message: '请输入手机号' },
      { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
    ],
  },
];

export const importFormSchema: FormSchema[] = [
  {
    label: 'excel',
    component: 'FileUpload',
    required: false,
  },
];
